                <div class="form-group key_item">
                    <label class="col-lg control-label">打印内容</label>
                      {ife 'sysset.printer' $list}
                    <div class="col-sm-9">
                        <div class="input-group">
                            <input type="text" name="key[]" class="form-control" value="{$list2}"/>
                            <div class="input-group-btn"><button class="btn btn-danger" type="button" onclick="$(this).parents('.key_item').remove()">删除</button></div>
                        </div>
                        <span class='help-block'>
                            {loop $style_list $key3 $value3}
                            <label class="radio-inline">
                                <input type="radio" value="{$key3}" name="value[{php echo isset($key2) ? $key2 : $kw}]" {if $values[$key2] == $key3}checked{/if}> {$value3}
                            </label>
                            {/loop}
                        </span>
                        <span class='help-block'>例如: <span class="">[商品名称]|[商品价格]|[商品数量]|[单商品合计]</span> ----  输入要打印的内容,如果打印一整句,请不要加 | 超出长度会折行,</span>
                    </div>
                     {else}
                       <div class="col-sm-9 col-xs-12">
                             <div class='form-control-static'>{$list2}</div>
                      </div>
                     {/if}
                </div>

                <script>
                    function len(s) {
                        s = String(s);
                        if (s.indexOf('|') != -1){
                            return 32;
                        }
                        return s.length + (s.match(/[^\x00-\xff]/g) || "").length;// 加上匹配到的全角字符长度
                    }
                    function limit(obj, limit) {
                        var val = obj.value;
                        if (len(val) > limit) {
                            val=val.substring(0,limit);
                            while (len(val) > limit){
                                val = val.substring(0, val.length - 1);
                            };
                            obj.value = val;
                        }
                    }
                    $("input[name='key[]']").keyup(function(){
                        limit(this,32);//20字节内
                    })
                </script>
  